//
//  ActiveDeckViewController.h
//  ActiveDeck
//
//  Created by Chiao-Wei Liu on 2011/1/16.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "GDataXMLNode.h"
#import "Init.h"
#import "ContainerController.h"
#import "PageViewController.h"
#import "PDFFactory.h"

@class HomeViewController;

@interface ActiveDeckViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIDocumentInteractionControllerDelegate>{

	IBOutlet HomeViewController *homeMode;
	NSMutableArray *slideVCSets;
    GDataXMLElement *userData;
    NSTimer *idleTimer;
    NSTimer *updateTimer;
    Init *initOB;
    
    int numberCorrect, numberIncorrect;
    NSMutableArray *allPages;
    
    ContainerController *contController;
    BOOL rotateMovie;
    
    NSNumber *upcomingSlideIndex;
    PageViewController *VC_Page;
    
    
    PDFFactory *pdfFactory;
    
    BOOL hasMovedOn;
    
    IBOutlet UIProgressView *pdfProgressBar;
    IBOutlet UIView *savingPDFView;
    IBOutlet UILabel *savingPDFLabel;
    IBOutlet UIButton *cancelPDFButton;
    IBOutlet UILabel *pdfPresentationLabel;
}

@property (nonatomic, retain) PageViewController *VC_Page;
@property (nonatomic, retain) ContainerController *contController;
@property (nonatomic, retain) Init *initOB;
@property (nonatomic, retain) NSTimer *idleTimer;
@property (nonatomic, retain) NSTimer *updateTimer;
@property (nonatomic, retain) GDataXMLElement *userData;
@property (nonatomic, retain) IBOutlet HomeViewController *homeMode; 
@property (nonatomic, retain) NSMutableArray *slideVCSets;
@property (nonatomic, retain) NSMutableArray *allPages;
@property (nonatomic, retain) NSNumber *upcomingSlideIndex;
@property (readwrite) int numberCorrect;
@property (readwrite) int numberIncorrect;
@property (readwrite) BOOL rotateMovie;

@property (nonatomic, retain) PDFFactory *pdfFactory;
@property (nonatomic, retain) IBOutlet UIProgressView *pdfProgressBar;
@property (nonatomic, retain) IBOutlet UIView *savingPDFView;
@property (nonatomic, retain) IBOutlet UILabel *savingPDFLabel;
@property (nonatomic, retain) IBOutlet UIButton *cancelPDFButton;
@property (nonatomic, retain) IBOutlet UILabel *pdfPresentationLabel;
@property (readwrite) BOOL hasMovedOn;

-(void)ShowCamera:(PageViewController *)sender;

- (void)loadViewWithSlide:(int)slideIndex 
                  display:(BOOL)show
                   pageID:(int)pageID;
- (void)loadViewWithSlide:(int)slideIndex 
                  display:(BOOL)show
                   pageID:(int)pageID
                         :(BOOL)isForPDF
                         :(BOOL)recordToHistory;
- (void)unloadViewWithSlide:(int)slideIndex;
- (void)changeSlide:(NSNumber *)slideIndex;
- (void)changeSlide:(NSNumber *)slideIndex 
             pageID:(int)pageID;
- (void)InitialSlideSession;
- (int)GetSlideIndexByID:(int)SectionID;
- (void)newPresentation;
- (void)jumpSection:(int)SectionID
         oldSection:(int)OldSectionID
           jumpPage:(int)Page;
- (void)notifySlideChange;

- (int)SearchSectionIdex:(int)SectionID;
- (void)updateUserData:(int)newSectionID;
- (void)resetIdleTimer;
- (void)idleTimerExceeded;
- (void)resetUpdateTimer;

- (void)updateAnswerCount:(int)numCorrect:(int)numIncorrect;

- (void)unloadViews:(int)sIndex;
- (void)SaveIntoFile;

- (void)rotateForMovie:(BOOL)shouldRotate;

- (void)exportToPDF:(NSMutableArray*)currentPosition;
- (void)pdfBarUpdate:(NSString*)progress;
- (IBAction)cancelPDF:(id)sender;
- (void)showPDFProgress;
- (void)hidePDFProgress;

- (void)navigateBackwards;
- (void)recordNavigationHistory:(BOOL)recordToHistory:(int)pageID:(int)slideIndex;
- (void)updateSecondaryChannelID:(int)key;
- (void)sendIdleMessage:(NSString*)channel;
- (BOOL)getIdleState;
@end

@interface SlidePagePair : NSObject {
    int slideID;
    int pageID;
}

@property (readwrite) int slideID;
@property (readwrite) int pageID;
@end
